<template>
  <div>
    <el-button type="primary" icon="el-icon-menu" size="mini" @click="handelCollapse"></el-button>

    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: current.path }" v-if="current">{{ current.label }}</el-breadcrumb-item>
    </el-breadcrumb>

    <el-dropdown>
      <span class="el-dropdown-link">
        <img src="../assets/logo.png" alt="" />
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item>个人中心</el-dropdown-item>
        <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import { mapState } from "vuex"
export default {
  name: "",
  data() {
    return {}
  },
  methods: {
    handelCollapse(){
      this.$store.commit('handelCollapse')
    },

    // 退出登录
    logout(){
      this.$confirm('您确定要退出登录吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$store.dispatch('resetInfo')
          this.$message.success('登出成功')
          this.$router.replace('/login')
        }).catch(() => {})
    }
  },
  computed: {
    ...mapState({
      current: (state) => state.tabs.currentMenu,
    }),
  },
}
</script>
<style lang="less" scoped>
div {
  height: 100%;

  .breadcrumb {
    display: inline-block;
  }

  .el-button {
    float: left;
    margin-top: 15px;
  }

  .el-dropdown {
    float: right;
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 1px solid #ccc;
      margin-top: 10px;
    }
  }
  .el-dropdown-link {
    cursor: pointer;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }

  .el-breadcrumb {
    display: inline-block;
    margin-left: 20px;
    line-height: 60px;
  }

  /deep/ span.el-breadcrumb__inner.is-link {
    color: #fff;
  }
}
</style>
